const div = document.querySelectorAll('.input')
for (let i = 0; i < div.length; i++) {
    div[i].addEventListener('click', function () {
        let input = div[i].querySelector('.input1')
        input.checked = 'checked'
    })
}
const bottom = document.querySelector('.sumbit')
bottom.onmouseover = function () {
    bottom.classList.add('blue')
    // console.log('1')
}
bottom.onmouseout = function () {
    bottom.classList.remove('blue')
}

bottom.addEventListener('click', function () {
    let sum = 0;
    for (let i = 0; i < 8; i++) {
        let temp = false

        let input = document.querySelectorAll(`#q${i + 1} input`)
        console.log(input)
        for (let j = 0; j < input.length; j++) {
            if (input[j].checked == true) {
                temp = true
                sum++
                // console.log(i + 1)
            }
        }
        if (temp == false) {
            document.querySelector(`#q${i + 1}`).scrollIntoView({ behavior: "smooth" })
            alert("有问题没有回答")
            break
        }
    }
    let nine_ = 0;
    const nine = document.querySelectorAll('#q9 .wai div')
    for (let i = 0; i < nine.length; i++) {
        if (nine[i].classList.contains('blue')) {

        }
        else {
            nine_++;
        }
    }
    // console.log(nine_)
    if (sum == 8) {
        if (nine_ == 10) {
            document.querySelector(`#q${9}`).scrollIntoView({ behavior: "smooth" })
            alert("有问题没有回答")
        }
        else {
            alert('谢谢你的参与，提交成功')
            window.location.href = 'index.html';
        }
    }

})

const nei = document.querySelectorAll('.nei')
// console.log(nei)
let cli = 0;
for (let i = 0; i < nei.length; i++) {
    // console.log(cli)
    nei[i].addEventListener('mouseover', function () {
        nei[i].classList.add("qianblue")
    })
    nei[i].addEventListener('mouseleave', function () {
        nei[i].classList.remove('qianblue')
    })
    nei[i].addEventListener('click', function () {
        // console.log(cli)
        nei[cli].classList.remove('blue')
        cli = i;
        nei[i].classList.add('blue')
    })
}




